home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Reference
/
the cmsp digests ('94-'97)
/
csmp digest Vol 3 No 081
< prev
next >
Wrap
Text File
|
1995-02-01
|
48KB
|
1,335 lines
C.S.M.P. Digest Wed, 01 Feb 95 Volume 3 : Issue 81
Today's Topics:
Apple events & non-applications (was Re: AppleScript and the Chooser... NOT...)
Can I '#include <foo-bar.h>' in C++ with Symantec or CodeWarrior?
Cool MacsBug Tricks
Globals with Quickdraw GX?
PPC glue for 68K library?
PowerPC Globals
Q: Is file on AppleShare volume?
Registering an NBP name?
What key code is Command-. (One for the FAQ)
dynamic-shared libs on MacOS ???
The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
(pottier@clipper.ens.fr).
The digest is a collection of article threads from the internet newsgroup
comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
regularly and want an archive of the discussions. If you don't know what a
newsgroup is, you probably don't have access to it. Ask your systems
administrator(s) for details. If you don't have access to news, you may
still be able to post messages to the group by using a mail server like
anon.penet.fi (mail help@anon.penet.fi for more information).
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
nef.ens.fr). Article threads are not added to the digest until the last
article added to the thread is at least two weeks old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The digest is officially distributed by two means, by email and ftp.
If you want to receive the digest by mail, send email to listserv@ens.fr
with no subject and one of the following commands as body:
help Sends you a summary of commands
subscribe csmp-digest Your Name Adds you to the mailing list
signoff csmp-digest Removes you from the list
Once you have subscribed, you will automatically receive each new
issue as it is created.
The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
Questions related to the ftp site should be directed to
scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
digest are available there.
Also, the digests are available to WAIS users. To search back issues
with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
-------------------------------------------------------
>From leonardr@netcom.com (Leonard Rosenthol)
Subject: Apple events & non-applications (was Re: AppleScript and the Chooser... NOT...)
Date: Tue, 17 Jan 1995 22:53:25 GMT
Organization: Aladdin Systems, Inc.
In article <mxmora-1701950834580001@xavier.sri.com>, mxmora@unix.sri.com
(Matthew Xavier Mora) wrote:
> In article <jens_alfke-1301951153550001@jensothermac.apple.com>,
> jens_alfke@powertalk.apple.com (Jens Alfke) wrote:
>
> > JLEWIS@HYRAX.IUPUI.EDU (Jeff Lewis) wrote:
> > > I'm wanting to write a script to pull of the chooser and logonto a
netware
> > > server. I can do this manually but cannot get a script to do this.
> >
> > It's impossible to script (or just send Apple events to) the Chooser,
> > because the Chooser is a desk accessory, not an application. Only
> > applications can be sent Apple events. For the same reason, you can't
> > script control panels.
>
> What? I have an fkey that sends AppleEvents. Why can't da's send apple events?
>
It is possiblie for any type of code to send Apple events, PROVIDED
that they live in an ae-aware process. So your FKEY will run fine IF you
use it in an application that has the 'high-level event aware' bit set,
however if you try it from one which does not, then you FKEY will fail.
The reason is that the process & AE manager collaborate to create the PPC
port for the process (AE's use PPC for transport) and w/o one you can't
send to anything other than yourself.
Recieving AE's in a non-application is also a logical problem, since an
AE target has to be a processID (or at least a PPC port) and things like
INIT's, FKEYs and DA's don't have such :(. HOWEVER, there if you think
about it, there is a trick. There are two types of event handlers,
application and system. Since system handlers are available anywhere, you
can install one from anywhere! So just have your code install a system
handler and the event can be sent to any process since the AEM will
forward unhandled events up to the system handlers.
Leonard
- ------------------------------------------------------------------------
Leonard Rosenthol Internet: leonardr@netcom.com
Director of Engineering AppleLink: MACgician
Aladdin Systems, Inc. GEnie: MACgician
---------------------------
>From denis@konishiki.Stanford.EDU (Denis Bohm)
Subject: Can I '#include <foo-bar.h>' in C++ with Symantec or CodeWarrior?
Date: 5 Jan 1995 11:04:21 -0800
Organization: Stanford University, CA 94305, USA
I am working on a large application which uses a number of
subsystems that are in different directories. This application
is intended to run on Mac, Windows, and Unix systems.
On Unix and Windows I can include a header "c_file.h" from directory
"b_dir" using:
#include <b_dir/c_file.h>
and tell the preprocessor which directories to search to find
the "b" directory when processing includes with something like
CC -I/a_dir
The Windows compiler I am using seems to interpret the "/" as a
directory seperator in the same way that Unix compilers do.
Looking at the Symantec C++ 7.0 documentation I don't see any
way to make this work. It seems that you can put source files
in directories, but you can't use the directory name in the
include directive. Is there some way to make this work in
Symantec C++, short of adding something like:
#ifdef Mac
#include "c_file.h"
#else
#include <b_dir/c_file.h>
#endif
to every file?
How about Code Warrior?
+++++++++++++++++++++++++++
>From Jaeger@fquest.com (Brian Stern)
Date: 5 Jan 1995 23:51:42 GMT
Organization: The University of Texas at Austin, Austin, Texas
In article <3ehfrl$cgt@konishiki.Stanford.EDU>,
denis@konishiki.Stanford.EDU (Denis Bohm) wrote:
< I am working on a large application which uses a number of
< subsystems that are in different directories. This application
< is intended to run on Mac, Windows, and Unix systems.
<
< On Unix and Windows I can include a header "c_file.h" from directory
< "b_dir" using:
<
< #include <b_dir/c_file.h>
<
< and tell the preprocessor which directories to search to find
< the "b" directory when processing includes with something like
<
< CC -I/a_dir
<
< The Windows compiler I am using seems to interpret the "/" as a
< directory seperator in the same way that Unix compilers do.
<
< Looking at the Symantec C++ 7.0 documentation I don't see any
< way to make this work. It seems that you can put source files
< in directories, but you can't use the directory name in the
< include directive. Is there some way to make this work in
< Symantec C++, short of adding something like:
<
< #ifdef Mac
< #include "c_file.h"
< #else
< #include <b_dir/c_file.h>
< #endif
<
< to every file?
<
< How about Code Warrior?
On the Mac the separator to indicate a subdirectory is ':'. A slash '/'
is a valid character in a filename. So 'b_dir/c_file.h' is a valid Mac
filename. You are probably stuck with using some ugly preprocessor hack.
Perhaps this might work:
#ifdef Mac
#define b_dir/
#endif
Both SC++ and CW will search through all the directories in your project
tree for the headers, and they both have ways to search any arbitrary
directory as well.
--
Brian Stern :-{)}
Toolbox commando and Menu bard
Jaeger@fquest.com
+++++++++++++++++++++++++++
>From lalonde@metrowerks.ca (Paul Lalonde)
Date: Thu, 05 Jan 1995 20:54:56 -0500
Organization: Metrowerks Inc
In article <3ehfrl$cgt@konishiki.Stanford.EDU>,
denis@konishiki.Stanford.EDU (Denis Bohm) wrote:
[snip]
> On Unix and Windows I can include a header "c_file.h" from directory
> "b_dir" using:
>
> #include <b_dir/c_file.h>
[snip]
> Looking at the Symantec C++ 7.0 documentation I don't see any
> way to make this work. It seems that you can put source files
> in directories, but you can't use the directory name in the
> include directive. Is there some way to make this work in
> Symantec C++, short of adding something like:
>
> #ifdef Mac
> #include "c_file.h"
> #else
> #include <b_dir/c_file.h>
> #endif
The contents of the #include filename are completely implementation-
dependent. You can't write code like this and expect it to work on all
platforms. For example, the Mac uses colons (:) instead of slashes (/)
to delimit directories in pathnames. None of the current Mac compilers
interpret slashes as pathname separators.
A clever workaround I've seen often is to rename your header to
"b_dir/c_file.h", which is a perfectly legal filename on the Mac.
Paul Lalonde
lalonde@metrowerks.ca
+++++++++++++++++++++++++++
>From pcastine@prz.tu-berlin.de (Peter Castine)
Date: Tue, 17 Jan 1995 11:32:00 GMT
Organization: PRZ TU-Berlin
In article <3ff20o$pmp@lll-winken.llnl.gov>,
Patrick C. Beard <beard@cs.ucdavis.edu> wrote:
>
>Sometimes you want to share code (#includes) between projects
>that aren't in the same folder. In both environments (THINK
>7.0.X & MW 5) you can use #include directives such as:
>
>#include "::common:shared.h"
>
>which would tell the compiler to look up in a sibling folder
>called common.
For this case it would be more to the point to use aliases.
Keep shared files inside a folder, make an alias to this folder and
put the alias in the "Aliases" folder in your project folder.
The ins and outs of this is all documented. Read the fabulous manual ;-)
--
Peter Castine | Oh, wenn jene alten, musikkundigen Gelehrten die
pcastine@prz.tu-berlin.de | Modernen hoerten, was wuerden sie tun, was
Process Control Center | wuerden sie sagen!
Technical University Berlin | -- Jacobus von Luettich (ca. 1330)
+++++++++++++++++++++++++++
>From jlgriswo@ingr.com (John Griswold)
Date: Tue, 17 Jan 1995 18:45:10 -0600
Organization: Intergraph (Core Drafting S/W)
In article <jens_alfke-1601951124010001@jensothermac.apple.com>,
jens_alfke@powertalk.apple.com (Jens Alfke) wrote:
> In article <3ehfrl$cgt@konishiki.Stanford.EDU>,
> denis@konishiki.Stanford.EDU (Denis Bohm) wrote:
> > Looking at the Symantec C++ 7.0 documentation I don't see any
> > way to make this work. It seems that you can put source files
> > in directories, but you can't use the directory name in the
> > include directive.
>
> You don't need to. Both the Symantec and Metrowerks compilers
> automatically search subdirectories. It doesn't matter where the files
> live as long as they are somewhere inside the folders you specify for your
> include paths. (I'm talking about the integrated environments here, not
> the MPW tools.)
>
> --Jens Alfke
Here's a simple little trick that I did to handle a mess of unix code that
I had to port a while back, where they used #include "sys/xxxx.h" in a
bunch of files. I created a folder under my project folder called
"unix/sys". In that folder I created files named "sys/tools.h",
"sys/uhdr.h", "sys/whatever.h", and so on. In those files they included
the needed "real" header files. Then these "glue" header files got me
past editing hundreds of source files. Of course I found lots of other
problems in the port but this worked for a bunch of files.
_~\\|///-_ John Griswold
// \\ Intergraph Corp.
/ == == \ Huntsville, AL
-(o)^(o)- (205) 730-2000
/ L \
// /|!|\ \\ jlgriswo@ingr.com
///`---'\\~ CompuServe: 74133,714
///|||\\\ AOL: JohnGRIZ
~?|||\\
---------------------------
>From kenlong@netcom.com (Ken Long)
Subject: Cool MacsBug Tricks
Date: Sat, 14 Jan 1995 03:45:15 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
This file was posted on AOL by Macneil Shonle (wrote BendImageFast,
worked on clut_fade 1.2, and wrote pict2pict-fader). It shows some
things that can be done with MacsBug, and requests input for more.
Enjoy!
-Ken-
p.s: I see the quotemarks came through as 'R' and 'S'. 0L!
>----------------------->
Cool MacsBug Tricks
This guide is to help you in using MacsBug. It is a list of
tricks, but it is just the tip of the iceberg of the cool stuff
you can do. This will start off with some relatively easy stuff
aimed towards beginners, then it will go into some more advanced
stuff. All of them are cool. When this says RDrop into MacsBug,S
it means that you should hit the programmers button (which is on
your computer, or on your keyboard, depending), if MacsBug is
installed, you should see the debugger screen ready to serve you.
You can Rdrop outS of MacsBug by typing RGS and then return, or by
holding down Command-G. Without further ado, lets begin!
Number Conversion MacsBug can be used as a quick hexadecimal to
decimal converter (and vise versa). I used to use PCalc (a great
application by the way) or some other conversion application, but
now I drop into MacsBug and type in the number I want to convert
and hit return. Example: You want to find out what R0x3ES is in
decimal, when in MacsBug type R$3ES and hit return. MacsBug will
then say:
$3E = $0000003E #62 #62 '%%%>'
The first number ($0000003E) is the value in hexadecimal that you
just typed in. The second number is what the value is as an
unsigned decimal, the third is the signed version. The last one
('%%%>') is the ASCII equivalent of the number (like: $41 is RAS,
$42 is RBS, $43 is RCS, and $3E is R>S), zeros (like the first
three bytes) are represented with the bullet (R%S).
You can also find out the decimal/hexadecimal equivalent of any
ASCII character by typing the letter balanced between two single
quotes. Example: Type in: 'A', you should get #65 as your answer.
By the way: the dollar sign means that the number is in
hexadecimal. Much like CUs R0xXXS notation, R$XXS is what assembly
people use. Numbers in MacsBug will default to hexadecimal, except
for when the hexadecimal number is a command or a regster
(example: ReaS is the command to restart the current application,
when you type in ea it will try this command, you must type in $ea
in order to avoid this conflict. I would try to get into the habit
of typing in a $ for every hexadecimal number anyway, itUs not too
hard to get used to.
Similarly, you have to type a # in order to express decimal
numbers, and you can use the conversion method just described
(type in the number, hit return) to find out its equivalent
hexadecimal number and ASCII character.
What Was My Monitor Size? HereUs an impresive way to show a friend
how many pixels horizontally and vertically they have on thier
monitor. Drop into MacsBug and type in: dm @@MainDevice GDevice.
This will show you the struct members of the MainDevice (which
happens to be a GDevice), you should see indented the gdPMap and
three lines below it will be bounds, with four numbers to the
right of it. These four numbers are the top, left, bottom and
right coordinates of the monitor, respectively.
The dm command is short for Rdisplay memory,S after you say RdmS
you type in the address of the memory you want to display.
MainDevice is a system global that is a handle (a pointer to a
pointer) to the main graphics device (the one with the menu bar).
The two @@ symbols are how you express double-indirection, in C
you use R*S to express indirection (dereferencing), which is in
put in prefix notation like R@S is. (People who program in Pascal
can use the postfix indirection notation by saying Rdm
MainDevice^^ GDeviceS.)
After you give the dm command the pointer, you give it the format
you want to see it diplayed as. You can say any number for the
number of bytes you want displayed, or you can say Rect to see the
first eight bytes of the memory in the form of a rectangle. You
can also use: Byte, Word, Long, SignedByte, SignedWord,
SignedLong, UnsignedByte, UnsignedWord, UnsignedLong, PString,
CString, and PixMap, GDevice, RGBColor, CGrafPort and any number
of other templates you may have installed.
Example: you know a rectangle is at address $00058EA6 and you want
to see what it is. All you have to do is type in Rdm $00058EA6
RectS and MacsBug will display it for you.
By the way: a template is a C struct (or a Pascal record) or some
other layout of memory that MacsBug knows about, you can type
RtmpS to find out all of the templates your version of MacsBug
has. But letUs say you want to find all of the templates that
begin with the word Rcolor,S all you would have to say is Rtmp
colorS, which will give you ColorSpec and ColorTable (if those
templates were installed).
Error Lookup DonUt you hate it when you are working in an
application, minding your own business, when all-of-a-sudden the
program quits and the system tells you an error of type X occured?
(Where RXS is the error number, like 1, 10 or -42.) There are many
applications made (like MacErrors) where you can look up these
numbers and find out what went wrong. MacsBug can also do this,
all you have to do is type RerrorS and then the error number. Keep
in mind that the error numbers the system gives you are decimal
(not hexadecimal), so you should put a R#S in front of it.
Example: The sytem tells you: RAn error of type 4 has occured.S
All you have to do is drop into MacsBug and type Rerror #4S,
MacsBug will then say R$0004 #4 zero divide errorS, which is
just what an error of type four is.
Note: This error feature is not in earlier versions of MacsBug, so
you may not have it.
The Simple Calculator You can use MacsBug as a simple calucator.
LetUs say you need to know what 7 times 17 is, type in R#7 * #17S,
and hit return. ThatUs all! The number 119 should now be on your
screen. It will be hidden in the line:
#7 * #17 = $00000077 #119 #119 '%%%w'
The lower case letter RwS is the 119th ASCII character, as the
previous line shows us. LetUs try another example, how about 5
plus 6? You would type in R#5 + #6S, and hit return. You should
then see:
#5 + #6 = $0000000B #11 #11 '%%%%'
MacsBug can also handle multiple operations at a time, like 5 plus
6 plus 10. If you want to say something even more advanced, like 5
plus 6 times 4, remember to put parentheses around the apropiate
numbers. MacsBug has no concept of orders of operations (like what
we humans use), itUs quite possible for it to add before it
multiplies. So say this: R#5 + (#6 * #4)S, which gives us #29,
instead of R#5 + #6 * #4S, which gives us #44.
You can use: +, -, *, /, MOD for arithmetic; AND (or &), OR (or
|), NOT (or !), XOR for boolean operations; and = (or ==), <> (or
!=), <, >, <=, >= for equality. So you can type in R#5 + #4 = #9S,
and MacsBug will give you a one, meaning that the equality you
just said was true. If you said R#5 + #4 = #10S, Macsbug will give
you a zero, meaning that the equality R5 plus 4 equals tenS is
false.
Moving The Mouse Here is a cool trick to move the mouse. It done
by setting memory, the mouse tracking variables specifically. So
IUd like to talk about setting memory beforehand. There are four
commands in MacsBug to set memory: SB (Set Byte), SW (Set Word),
SL (Set Long), and SM (Set Memory). You give each of these
commands an address first, and then the values of what you want to
set the memory to. Example: There is a byte that you have the
address of that you want to set to ten, you say RSB $XXXXXXXX
#10S, where $XXXXXXXX is the address of the byte. Another example:
There is a long that you have the address of that you want to set
to R$4D616320S, you say RSL $XXXXXXXX $4D616320S, again where
$XXXXXXXX is the address of the long. (You can use the SM command
the same way in the case that the length you want to set is not 1,
2 or 4 bytes long. You use SW when you want to set a word (2
bytes) ).
If you are familiar with Points (the vertical and horizontal
coordinates of a point on the graf plane), you should know that
they take up four bytes in memory. The high two bytes (the high
word) is the vertical coordinate, and the low two bytes (the low
word) is the horizontal coordinate. There are two global variables
that are both Points, one called MTemp, the other called RawMouse,
these variables are the information the Macintosh uses for the
cursor. You can set these points by using SL. There is also a byte
called CrsrNew, set this byte to 1 when you want to notify the
Macintosh that the cursor posistions have changed. This is how you
move the mouse to point (5,J6), near the upper-left corner of the
screen, by typing in these three commands (hit return after each
line):
SL MTemp $00060005 SL RawMouse $00060005 SB CrsrNew #1
Make sure MTemp and RawMouse have the same value. Now type
Command-G to see your newly moved cursor.
Recovering From a Hung Serial Port Sometimes when youUre
AppleTalking or modeming and something goes wrong (like you switch
the modem off while data is being sent to it), the comptuer will
hang. The mouse will still move, but clicking will have no effect.
HereUs the solution:
Drop into MacsBug. You should see the routine name R_vSyncWaitS
plus something as the current location. If you donUt, you probably
hit the system while it was doing something else. Hit Command-G to
get back out of MacsBug, and try again. After a few tries you
should find _vSyncWait.
_vSyncWait is the routine that the system uses to wait for some
input from a serial port. If you can read assembly code, youUll
see that itUs pretty simple. HereUs the dump of the significant
part:
+0000 4080BB8C MOVE.W $0010(A0),D0
| 3028 0010 +0004 4080BB90 BGT.S _vSyncWait
; 4080BB8C | 6EFA
Register A0 is pointing to a system data structure, in which a
word will be cleared when the awaited input arrives. The MOVE.W
instruction grabs this word and puts it into register D0. The
BGT.S instruction then Branches back to the MOVE.W if the byte it
just fetched is Greater Than zero (hence BGT). So it happens that
this byte is never going to arrive for whatever reason, but the
computer is going to wait for eternity. The secret to fixing this
is to use Command-T to go step along until the MOVE.W instruction
is displayed as the current instruction. Now use the RswS command
to set R@(a0+10)S to zero:
sw @(a0+10) 0
Then hit Command-T twice more. The MOVE.W instruction will take
the zero you just set into memory and put it in D0, so the D0
display on the right of the screen should have its right four
digits all zeros. Then when you execute the BGT.S instruction, it
should not go back to the MOVE.W since zero is not greater than
zero.
Hit Command-G to go. If this was the only byte the software was
waiting for, then it should continue running, although it may go a
little crazy because itUs been suddenly disconnected from whatever
peripheral it was talking to. Quit the program, fix your hardware,
and try again.
Credits As the saying goes: Rgive credit where credit is due.S The
authors of this are Macneil Shonle and Dustin Mitchell. Email
RMacneilS@aol.comS if you got a trick or two up your sleeve, IUll
put it in the next CMT so everyone else can know about it. (We
want the really wacky tricks in particular.)
Thanks for reading!
---------------------------
>From N.r.h. Black <nrhblack@delphi.com>
Subject: Globals with Quickdraw GX?
Date: Fri, 13 Jan 95 12:22:10 -0500
Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
Posted for a friend called Debbie Dittmer on 408 986 0115 X 3642
(1) Where in cyberspace do people discuss problems with writing and
using printer drivers and GX?
(2) What are the GX "instances" that replace globals, what messages are
included in such "instances", and what message is best for global init
and destroy in each "instance"? i.e. when can a developer be sure the
globals inited are the globals being accessed?
thanks Henry
+++++++++++++++++++++++++++
>From mclow@san_marcos.csusm.edu (Marshall Clow)
Date: Fri, 13 Jan 1995 21:15:58 -0800
Organization: Aladdin Systems
In article <Bcw6RYy.nrhblack@delphi.com>, N.r.h. Black
<nrhblack@delphi.com> wrote:
> Posted for a friend called Debbie Dittmer on 408 986 0115 X 3642
She can mail me her questions, if you like (or you can).
> (1) Where in cyberspace do people discuss problems with writing and
> using printer drivers and GX?
>
I don't think that there are that many people writing GX printer
drivers. I could be wrong, tho. [ There certainly are more GX driver
developers than QuickDraw driver developers. ]
> (2) What are the GX "instances" that replace globals, what messages are
> included in such "instances", and what message is best for global init
> and destroy in each "instance"? i.e. when can a developer be sure the
> globals inited are the globals being accessed?
>
A GX printer driver, during the course of a print job, gets
"instantiated" several times. Once is "in" the application doing the
printing, for the print dialogs and spooling. Once is "in" the Finder, to
handle the desktop printer window and menus. Once is "in" PrinterShare GX,
which is where the spool file is processed, and the printer commands are
generated, and the data is sent to the printer (usually).
Each "instantiation" of the driver is begun by the sending of the
message "Initialize", and ended by the sending of the message "Shutdown".
If you need global state (that is always around), then you should allocate
it in Initialize, and free it in Shutdown. OTOH, if you have global state
that is important only while you are talking to the printer, you might
want to consider allocating it in OpenConnection, and freeing it in
CloseConnection. Whatever works for you.
APDA has (finally) started selling the Developer University's
self-paced course in how to write drivers. Six lessons in this course are
about GX printer drivers. Plug. :-) [ I wrote that part, and no, I don't
get royalties. ]
-- Marshall
--
Marshall Clow
Aladdin Systems
mclow@san_marcos.csusm.edu
---------------------------
>From drabe@MCS.COM (Daniel Rabe)
Subject: PPC glue for 68K library?
Date: 12 Jan 1995 17:47:51 -0600
Organization: Another MCSNet Subscriber, Chicago's First Public-Access Internet!
I'm having some problems trying to write glue code so that my PPC app
can call a 68K library.
I have an MPW 68K library (.o) that contains about 20 functions that
my PowerPC program wants to link against. I know how to get a routine
descriptor with the appropriate proc info, but how do I get the address
of one of the 68K functions to pass to NewRoutineDescriptor? I can't
imagine that any of the PPC linkers can read the 68K .o files, can they?
I've considered creating a 68K CODE resource for each function, but then
I'd have over 20 CODE resources floating around (one for each function);
plus, this library requires the C Runtime library, and if I linked it into
each CODE resource, strange things might happen (or, at the very least,
each resource would be BIG). I couldn't find any documentation that says
how this should be done. Any suggestions?
Thanks!
Daniel Rabe
+++++++++++++++++++++++++++
>From Jaeger@fquest.com (Brian Stern)
Date: 13 Jan 1995 06:13:40 GMT
Organization: The University of Texas at Austin, Austin, Texas
In article <3f4f37$97m@Mercury.mcs.com>, drabe@MCS.COM (Daniel Rabe) wrote:
< I'm having some problems trying to write glue code so that my PPC app
< can call a 68K library.
<
< I have an MPW 68K library (.o) that contains about 20 functions that
< my PowerPC program wants to link against. I know how to get a routine
< descriptor with the appropriate proc info, but how do I get the address
< of one of the 68K functions to pass to NewRoutineDescriptor? I can't
< imagine that any of the PPC linkers can read the 68K .o files, can they?
< I've considered creating a 68K CODE resource for each function, but then
< I'd have over 20 CODE resources floating around (one for each function);
< plus, this library requires the C Runtime library, and if I linked it into
< each CODE resource, strange things might happen (or, at the very least,
< each resource would be BIG). I couldn't find any documentation that says
< how this should be done. Any suggestions?
<
< Thanks!
< Daniel Rabe
I recently did this with an MPW .o lib. You make a code resource that has
one function, main. You include your 68K library in the project. You
pass into main a pointer to a struct that holds the addresses of all of
the routines in the library and your main routine simply fills out this
struct. When you want to call one of the routines in the library you
simply use CallUniversalProc and pass in the address of that routine and
the appropriate upppProcInfo. Don't bother actually making upps. This
all works neatly. You can write appropriate defines so that your 68K app
and PPC app use the appropriate calling conventions. In the project that
I'm working on I include the .o lib in the 68K version and the code
resource in the PPC version. Both use the same header file.
Good luck,
--
Brian Stern :-{)}
Toolbox commando and Menu bard
Jaeger@fquest.com
+++++++++++++++++++++++++++
>From isis@netcom.com (Mike Cohen)
Date: Fri, 13 Jan 1995 19:47:13 GMT
Organization: ISIS International
drabe@MCS.COM (Daniel Rabe) writes:
>I'm having some problems trying to write glue code so that my PPC app
>can call a 68K library.
>I have an MPW 68K library (.o) that contains about 20 functions that
>my PowerPC program wants to link against. I know how to get a routine
>descriptor with the appropriate proc info, but how do I get the address
>of one of the 68K functions to pass to NewRoutineDescriptor? I can't
>imagine that any of the PPC linkers can read the 68K .o files, can they?
>I've considered creating a 68K CODE resource for each function, but then
>I'd have over 20 CODE resources floating around (one for each function);
>plus, this library requires the C Runtime library, and if I linked it into
>each CODE resource, strange things might happen (or, at the very least,
>each resource would be BIG). I couldn't find any documentation that says
>how this should be done. Any suggestions?
>Thanks!
>Daniel Rabe
How about ONE code resource, which either has a jump table at the beginning
or takes a selector to dispatch to the correct function?
--
Mike Cohen - isis@netcom.com
NewtonMail, eWorld: MikeC / ALink: D6734 / AOL: MikeC20
Home Page: ftp://ftp.netcom.com/pub/is/isis/home.html
PUSH THE BUTTON, FRANK... OR SOMEONE?
+++++++++++++++++++++++++++
>From sw@network-analysis-ltd.co.uk (Sak Wathanasin)
Date: Sat, 14 Jan 95 00:52:39 GMT
Organization: Network Analysis Ltd
In article <3f4f37$97m@Mercury.mcs.com> (comp.sys.mac.programmer),
drabe@MCS.COM (Daniel Rabe) writes:
> imagine that any of the PPC linkers can read the 68K .o files, can they?
> I've considered creating a 68K CODE resource for each function, but then
> I'd have over 20 CODE resources floating around (one for each function);
No, create one code resource that dispatches to each of the 20 lib funcs that
you want to call. Look in the PPC examples folder on ETO, or the PPC-68K
example on the CodeWarrior CD.
Sak Wathanasin
Network Analysis Limited
178 Wainbody Ave South, Coventry CV3 6BX, UK
Internet: sw@network-analysis-ltd.co.uk
uucp: ...!uknet!nan!sw AppleLink: NAN.LTD
Phone: (+44) 203 419996 Mobile:(+44) 850 587411 Fax: (+44) 203 690690
---------------------------
>From mauerj@aol.com (MauerJ)
Subject: PowerPC Globals
Date: 13 Jan 1995 01:42:14 -0500
Organization: America Online, Inc. (1-800-827-6364)
I need to access my application's global variables from a Time Manager
task. How can I do this running in native PowerPC mode?
The way the Inside Mac lists to do it with 68K code is to set up a new
tmInfo structure containing tmTask and a tmRefCon on the end of it. That
way,you can store your app's A5 world in the refcon and access it through
the A1 register in the Time Manager task.
Herein lies my problem-how am I supposed to get at the refcon without an
A1 register? Should I try to use this type of method with the native code?
Or is there some really easy solution to this that I just can't see?
I hope someone out there knows the answer to this one,because I haven't
found it yet.
Thanks,
MauerJ
+++++++++++++++++++++++++++
>From rudolph@unixg.ubc.ca (Chris Rudolph)
Date: Thu, 12 Jan 1995 23:58:23 -0800
Organization: Motion Works International
In article <3f57c6$2ju@newsbf02.news.aol.com>, mauerj@aol.com (MauerJ) wrote:
> I need to access my application's global variables from a Time Manager
> task. How can I do this running in native PowerPC mode?
>
> The way the Inside Mac lists to do it with 68K code is to set up a new
> tmInfo structure containing tmTask and a tmRefCon on the end of it. That
> way,you can store your app's A5 world in the refcon and access it through
> the A1 register in the Time Manager task.
>
> Herein lies my problem-how am I supposed to get at the refcon without an
> A1 register? Should I try to use this type of method with the native code?
> Or is there some really easy solution to this that I just can't see?
>
> I hope someone out there knows the answer to this one,because I haven't
> found it yet.
>
> Thanks,
> MauerJ
Mauer,
Your in luck. One of the nicetys of the Time Manager on the PowerPC is
that pointer to your structure is passed in as a parameter:
example:
#ifndef powerc
typedef struct
{
VBLTask theTask;
long A5;
// Anything else you want to add
} MyVBLTask, *MyVBLTaskPtr;
// Function prototype
pascal void MyVBLProc( VBLTaskPtr inVBLTask );
// Inline function to get at your globals
pascal MyVBLTaskPtr GetVBLTaskPtr() = 0x2E88; // MOVE.L A0,A7;
#else
typedef struct
{
VBLTask theTask;
// Anything else you want to add
} MyVBLTask, *MyVBLTaskPtr;
pascal void MyVBLProc( void );
#endif
// ===========================================================================
// MyVBLProc
//
#ifndef powerc
pascal void MyVBLProc( void );
{
long oldA5;
MyVBLTaskPtr theTask = GetVBLTaskPtr();
// Save and setup your A5 globals
oldA5 = SetA5( theTask->A5 );
... Do some stuff here for you VBL Task
// Restore the saved A5
(void) SetA5( oldA5 );
}
#else
pascal void MyVBLProc( VBLTaskPtr inVBLTask )
{
// Don't need to setup or restore anything, plus
// Your structure is within easy grasp
... Do some stuff here for you VBL Task
}
#endif
- -------------------------------------------------------------------
Chris Rudolph, Senior Engineer,
Technology Works.
Motion Works International.
Internet: rudolph@unixg.ubc.ca
AppleLink: D2276 ( Subject: Attn: Chris Rudolph )
- -------------------------------------------------------------------
---------------------------
>From mhl@icf.hrb.com (mark)
Subject: Q: Is file on AppleShare volume?
Date: 12 Jan 95 11:16:57 EST
Organization: HRB Systems, Inc.
Dear c.s.m.p.h
This is kind of a fill in the blank question...
#include <Types.h>
OSErr FileIsOnAnAppleShareVolume(
short aFileReferenceNumber, /* refNum of file in question */
Boolean *onAppleShare /* returned as 'true' if the referenced
* file is on an AppleShare volume, or
* 'false' otherwise. */
) {
OSErr theError = noErr;
...
if ((theError == noErr) && (...)) {
*onAppleShare = true;
} else {
*onAppleShare = false;
}
return theError;
}
In searching throught NIM:Files I _did_ find a structure that tells
whether a volume is AppleShare or not. Unfortunately, I could not find a
routine which returned that data structure.
Any takers on how to flesh out this routine?
--
Mark H. Linton
PS: Bring me the blue pages.
+++++++++++++++++++++++++++
>From jumplong@aol.com (Jump Long)
Date: 18 Jan 1995 00:01:10 -0500
Organization: America Online, Inc. (1-800-827-6364)
>In searching throught NIM:Files I _did_ find a structure that tells
>whether a volume is AppleShare or not. Unfortunately, I could not find a
>routine which returned that data structure.
>
>Any takers on how to flesh out this routine?
Using routines GetFileLocation and HGetVolParms, and macro isNetworkVolume
from Apple's MoreFiles sample code makes this easy:
OSErr FileIsOnNetworkVolume(short refNum, Boolean *onNetworkVolume)
{
OSErr result;
short vRefNum;
long dirID;
GetVolParmsInfoBuffer volParmsInfo;
long infoSize;
result = GetFileLocation(refNum, &vRefNum, &dirID, NULL);
if ( result == noErr )
{
infoSize = sizeof(GetVolParmsInfoBuffer);
if ( HGetVolParms(NULL, vRefNum, &volParmsInfo, &infoSize) == noErr )
{
*onNetworkVolume = isNetworkVolume(volParmsInfo);
}
else
{
/* Volume must support GetVolParms to be a netowrk volume */
*onNetworkVolume = false;
}
}
return ( result );
}
Note that this routine simply identifies network volumes.
If you want to specifically check for AppleShare network volumes, you
should call PBHGetVInfo to get the volume's drive number, search the drive
queue to find the drvQEl for the drive and get the driver reference number
from the drvQEl, and then compare that driver reference number to the
driver reference number of the .AFPTranslator driver (the driver that owns
all AppleShare volumes).
- Jim Luther
---------------------------
>From patrickd@sandstone.WPI.EDU (Patrick D.)
Subject: Registering an NBP name?
Date: 15 Jan 1995 04:02:50 GMT
Organization: Satellite of Love - Satellite.res.wpi.edu
How do I go about registering an NBP name on an AppleTalk network? I'd like
some sample source code that works with Think C 5.0 or 6.0 or Think Pascal.
...and I kinda need the source code to work. I've asked in the past and the
code I got wouldn't compile.
--
-Patrick Delahanty | BEWARE!: MST3K, the TICK, TMBG, Phish, and
PatrickD@Satellite.res.wpi.edu| Star Trek fan! Macintosh Evangelist & Guru
- ----------------------------+--------------------------------------------
http://www.wpi.edu/~patrickd/ | Veteran MST3K Fan - Info Club # 6563
+++++++++++++++++++++++++++
>From jumplong@aol.com (Jump Long)
Date: 18 Jan 1995 00:17:45 -0500
Organization: America Online, Inc. (1-800-827-6364)
>How do I go about registering an NBP name on an AppleTalk network? I'd
>like some sample source code that works with Think C 5.0 or 6.0 or Think
>Pascal. ...and I kinda need the source code to work. I've asked in the
>past and the code I got wouldn't compile.
Here's a C port of the code I wrote for IM: Networking.
- Jim Luther
/*
** Registers a entity with the specified object and type on the
** specified socket. The pointer to the NamesTableEntry is returned in
** ntePtr if the function returns noErr.
*/
OSErr MyRegisterName(ConstStr32Param entityObject, ConstStr32Param
entityType,
short socket, NamesTableEntry **ntePtr)
{
MPPParamBlock mppPB;
OSErr result;
Str32 entityZone = "\p*";
/* Allocate non-relocatable memory in the system heap for the names table
entity */
*ntePtr = (NamesTableEntry *) NewPtrSys((Size) sizeof(NamesTableEntry));
if ( ntePtr == NULL )
{
result = MemError(); /* Return memory error */
}
else
{
/* Build the names table entity */
NBPSetNTE((Ptr) *ntePtr, (Ptr) entityObject, (Ptr) entityType, (Ptr)
entityZone, socket);
/* ioRefNum and csCode are filled in by PRegisterName's glue */
mppPB.NBPinterval = 0x0f; /* Reasonable values for the interval and */
mppPB.NBPcount = 0x03; /* retry count */
mppPB.NBPentityPtr = (Ptr) *ntePtr; /* Pointer to NamesTableEntry */
mppPB.NBPverifyFlag = (char) true; /* Make sure name is unique */
result = PRegisterName(&mppPB, false); /* Register the name */
if ( result != noErr )
DisposePtr((Ptr) *ntePtr); /* If error, give space back */
}
return ( result );
}
---------------------------
>From rjohnson@ (Ray Johnson)
Subject: What key code is Command-. (One for the FAQ)
Date: 16 Jan 1995 23:17:34 GMT
Organization: Sun Microsystems, Inc. Mt. View, Ca.
In the book Inside Mac "Macintosh Toolbox Essentials" concerning the
Event Manager, they have a section about looking for Command-. event.
They show sample code that implies that the period key may change
if the user changes the script. However, it really doesn't show the
best way to look for the Command-. event.
What is the best way to look for Command-. ???
This seems like a good question to be in the FAQ. (Even if it isn't
asked alot - it should be!)
Ray
+++++++++++++++++++++++++++
>From Anders.Wahlin@hum.gu.se (Anders Wahlin)
Date: Tue, 17 Jan 1995 07:38:43 GMT
Organization: Hum Fak:s Dataservice
In article <3feuqe$baa@engnews2.Eng.Sun.COM>, rjohnson@ (Ray Johnson) wrote:
> In the book Inside Mac "Macintosh Toolbox Essentials" concerning the
> Event Manager, they have a section about looking for Command-. event.
> They show sample code that implies that the period key may change
> if the user changes the script. However, it really doesn't show the
> best way to look for the Command-. event.
>
> What is the best way to look for Command-. ???
>
> This seems like a good question to be in the FAQ. (Even if it isn't
> asked alot - it should be!)
>
> Ray
When I'm looking for a Command-. in a dialog, I call this function in the
dialog filter:
Boolean Cmd_Period(short theModifier, char theKey) {
if (((theModifier & cmdKey) != 0) && (theKey == '.')) return (TRUE);
return (FALSE);
}
Like this:
if (Cmd_Period(theEvent->modifiers, theChar)) {
/* Cancel */
}
When I'm looking for a Command-. in an application that isn't using events
I call this function:
Boolean KeyPressed(unsigned short theCharCode) {
unsigned char keyMap[16];
GetKeys((long *)keyMap);
return ((keyMap[theCharCode>>3] >> (theCharCode& 7)) & 1);
}
Like this:
if ( (KeyPressed(55)) && (KeyPressed(47)) ) {
/* Cancel */
}
--
Anders Wahlin
Anders.Wahlin@hum.gu.se
+++++++++++++++++++++++++++
>From stk@DoBag.IN-Berlin.DE (Stefan Kurth)
Date: Wed, 18 Jan 1995 00:51:26 +0100
Organization: none
Anders Wahlin <Anders.Wahlin@hum.gu.se> wrote:
> When I'm looking for a Command-. in a dialog, I call this function in the
> dialog filter:
>
> Boolean Cmd_Period(short theModifier, char theKey) {
> if (((theModifier & cmdKey) != 0) && (theKey == '.')) return (TRUE);
> return (FALSE);
> }
Now this is of course exactly what you should -not- be doing, because it
doesn't work on keyboards where the '.' character is shifted.
Go read NIM:Text (appendix C, pages C-23 and C-24), it explains how to
handle it correctly.
> Boolean KeyPressed(unsigned short theCharCode) {
> unsigned char keyMap[16];
>
> GetKeys((long *)keyMap);
> return ((keyMap[theCharCode>>3] >> (theCharCode& 7)) & 1);
> }
...
> if ( (KeyPressed(55)) && (KeyPressed(47)) ) {
> /* Cancel */
> }
Huuh, even worse. Don't make assumptions on the virtual key codes of
characters.
________________________________________________________________________
Stefan Kurth Berlin, Germany stk@dobag.in-berlin.de
+++++++++++++++++++++++++++
>From jens_alfke@powertalk.apple.com (Jens Alfke)
Date: Wed, 18 Jan 1995 20:41:20 GMT
Organization: Apple Computer, Inc.
Anders.Wahlin@hum.gu.se (Anders Wahlin) wrote:
> When I'm looking for a Command-. in a dialog, I call this function in the
> dialog filter:
The trouble with that function is that it assumes that no shift (or other)
modifier is needed to get a period. On non-English keyboards where you do
need a modifier, the code you gave won't work.
There is an Apple tech note on "International Canceling" that gives sample
code that will work on any Macintosh worldwide.
Jens Alfke_________OpenDoc Geometer_________jens_alfke@powertalk.apple.com
OpenDoc info: FTP to cil.org
Visit Scenic Flood Control Dam No. 3.
---------------------------
>From steph@bebop.frcl.bull.fr (Stphane Knigsdrfer)
Subject: dynamic-shared libs on MacOS ???
Date: 9 Jan 1995 09:21:56 GMT
Organization: BULL S.A.
--
Hi NetWorkers !
Could anybody tell me if MacOS (and from which version) supports
dynamic/shared libraries ?
Thanx, Steph.
===============================================================================
Stephane Konigsdorfer
(Poste courrier A5/146) Tel.: +33 (1) 30 80 70 70
BULL S.A. Fax.: +33 (1) 30 80 77 99
Rue Jean Jaures
78340 Les Clayes-sous-Bois E-mail: S.Konigsdorfer@frcl.bull.fr
FRANCE
===============================================================================
+++++++++++++++++++++++++++
>From Joern Loviscach <jl@lovia.teuto.de>
Date: 9 Jan 1995 21:08:57 GMT
Organization: POP Contrib.Net Netzdienste GmbH, Bielefeld, Germany
steph@bebop.frcl.bull.fr (Stphane Knigsdrfer) wrote:
> Could anybody tell me if MacOS (and from which version) supports
> dynamic/shared libraries ?
Yes. On PPC via code fragment manager, on 68K via shared library
manager (quite new). Concerning the code fragment manager, take
a look into "Inside Macintosh: PowerPC System Software".
It's available on ftp://ftp.info.apple.com/.
- -Joern Loviscach
+++++++++++++++++++++++++++
>From jwbaxter@olympus.net (John W. Baxter)
Date: Mon, 09 Jan 1995 19:08:50 -0800
Organization: Internet for the Olympic Peninsula
In article <3es8l9$vp7@linteuto.teuto.de>, Joern Loviscach
<jl@lovia.teuto.de> wrote:
> steph@bebop.frcl.bull.fr (Stphane Knigsdrfer) wrote:
>
> > Could anybody tell me if MacOS (and from which version) supports
> > dynamic/shared libraries ?
>
> Yes. On PPC via code fragment manager, on 68K via shared library
> manager (quite new). Concerning the code fragment manager, take
> a look into "Inside Macintosh: PowerPC System Software".
> It's available on ftp://ftp.info.apple.com/.
Apple Shared Library Manager isn't all *that* new...it goes back (in
released form) at least to day 1 of FoxPro 2.5 (the current FoxPro is
2.6). [FoxPro 2.5 used Microsoft's "Shared Code Manager" which in turn
used Apple Shared Library Manager.]
And Code Fragment Manager is coming to the 68K world (public knowledge,
thanks to the OpenDoc CD available to all), probably this year (common
guess).
Apple Shared Library Manager is happiest with C++ (it can work in a
limited way with C or Pascal). And it's only happy when the client code
is built with the same C++ which built the library. But it does allow
client code to compile a subclass of a class defined in the shared
library.
SOM (IBM's acronym and product) comes with OpenDoc, and relieves the
requirement that the library and client come from the same compiler.
--John
--
John Baxter Port Ludlow, WA, USA [West shore, Puget Sound]
Isn't C fun?
jwbaxter@pt.olympus.net
+++++++++++++++++++++++++++
>From caleb@delbruck.pharm.sunysb.edu (Caleb Strockbine)
Date: 12 Jan 1995 19:25:11 GMT
Organization: SUNY Stony Brook
In article <3es8l9$vp7@linteuto.teuto.de> Joern Loviscach <jl@lovia.teuto.de> writes:
>steph@bebop.frcl.bull.fr (Stphane Knigsdrfer) wrote:
>
>> Could anybody tell me if MacOS (and from which version) supports
>> dynamic/shared libraries ?
>
>Yes. On PPC via code fragment manager, on 68K via shared library
>manager (quite new). Concerning the code fragment manager, take
>a look into "Inside Macintosh: PowerPC System Software".
>It's available on ftp://ftp.info.apple.com/.
I spoke with someone from Apple at the San Fransisco MacWorld Expo
who told me that the Code Fragment Manager is now available for
68K as well as PPC. He recommended CFM for all my shared library
needs.
Caleb Strockbine
---------------------------
End of C.S.M.P. Digest
**********************